import React from "react"
import Modal from 'antd/lib/modal/Modal'
import {connect} from 'umi'
import {Table} from "antd"
import {ColumnsType} from "antd/lib/table/interface"
const Recent=(props:any)=>{
    const {itinerary,showItinerary}=props
    const {dispatch,model}=props
    const onCancel=()=>{
        dispatch({
            type: "clientInfo/save",
            payload: {
                showEdit: false,
                isEdit:false,
                showSearch:false,
                showItinerary:false
            }
        })
    }
    const onFinish=()=>{
        dispatch({
            type: "clientInfo/save",
            payload: {
                showEdit: false,
                isEdit:false,
                showSearch:false,
                showItinerary:false
            }
        })
    }
    const columns: ColumnsType<object> = [{
        title: '序号',
        render: (row: any, k: any, index: number) => <span>{index + 1}</span>,
        width: 80,
        align: 'center'
    }, {
        title:'姓名',
        dataIndex:'fullname'
    },
    {
        title:'座位号',
        dataIndex:'seat_no'
    },
    {
        title: "航班号",
        dataIndex:'flight_id'
    },
    {
        title:"出发日期",
        dataIndex:'s_date'
    },
    {
        title:"出发地点",
        dataIndex:'departure_name'
    },{
        title:"到达地点",
        dataIndex:'destination_name'
    }
]
    return ( 
        <Modal width="800px"visible={showItinerary}  getContainer={false} title="查询最近行程" onCancel={onCancel} onOk={onFinish} >
        <Table columns={columns} dataSource={itinerary}/>
        </Modal>
    )
}
const mapStateToProps=(state:any)=>({
    model:state.clientInfo.current,
    showItinerary:state.clientInfo.showItinerary,
    itinerary:state.clientInfo.itinerary
})
export default connect(mapStateToProps)(Recent)